package proxy;

public class StaticProxyPayServiceImpl implements PayService{

    public PayService payService;

    public StaticProxyPayServiceImpl(PayService payService){
        this.payService = payService;
    }

    @Override
    public int save(int accountNo, int productId) {
        openTransaction();
        int id = payService.save(accountNo, productId);
        commitTransaction();
        return id;
    }

    @Override
    public String callback(String outTradeNo) {
        openTransaction();
        String value = payService.callback(outTradeNo);
        commitTransaction();
        return value;
    }

    public static void openTransaction(){
        System.out.println("开启事务");
    }

    public static void commitTransaction(){
        System.out.println("提交事务");
    }
}
